package com.roger.myHome.weather;

import com.roger.myHome.util.HttpURLConnectionUtil;
import com.roger.myHome.util.StringUtils;

import java.util.List;
import java.util.Map;

import com.roger.myHome.entity.vo.Forecast;

public class WeatherDemo {
    public static void main(String[] args) throws Exception {

        //System.out.println("Testing 1 - Send Http GET request");
        StringBuffer response = HttpURLConnectionUtil.sendGet("http://t.weather.itboy.net/api/weather/city/101190401");

        Map hp = StringUtils.jsonToMap(response.toString());
        String data = hp.get("data").toString();
        Map hp2 = StringUtils.jsonToMap(data);

        String forecast = hp2.get("forecast").toString();
        System.err.println(forecast);

        List<Forecast> obj2 = StringUtils.jsonToList(forecast,Forecast.class);

        System.out.println(obj2);
    }
}
